<?php
namespace app\web\validate;

use think\Validate;

/**
 * 行为验证器
 * @package app\menus\validate
 * @author
 */
class Vote extends Validate
{
    //定义验证规则
    protected $rule = [
        'id|ID'  => 'require|number',
        'goods_id|商品id'  => 'require|number',
        'num|商品数量'  => 'require|number',
        'sku_id|商品属性'  => 'require|number',
        'sku_val|属性值'  => 'require',
    ];
    //定义验证提示
    protected $message = [
        'id.require' => '无效的数据',
        'id.number' => '无效的数据',
        'goods_id.require' => '缺少参数',
        'goods_id.number' => '参数格式不正确',
        'num.require' => '缺少参数',
        'num.number' => '参数格式不正确',
        'sku_id.require' => '缺少参数',
        'sku_id.number' => '参数格式不正确',
        'sku_val.require' => '缺少参数',
    ];
    //定义验证场景
    protected $scene = [
        'add'   =>  ['goods_id','num','sku_id','sku_val'],
        'update'   =>  ['id','goods_id','num','sku_id','sku_val'],

    ];
}
